package Unicart.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class InternalPage extends AnyPage {

  public InternalPage(PageManager pages) {
		super(pages);
  }
	
  public InternalPage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.linkText("Выйти")));
    return this;
  }
  
  @FindBy(linkText = "Личная информация")
  //css = "b-page-content_in a[href $= 'account']" 
  private WebElement userProfileLink;

  @FindBy(linkText = "Выйти")
  //css = "b-page-content_in a[href $= 'logout']"
  private WebElement logoutLink;
  
  public UserProfilePage clickUserProfilePage() {
    userProfileLink.click();
    return pages.userProfilePage;
  }

  public MainPage clickLogoutLink() {
    logoutLink.click();
    //wait.until(alertIsPresent()).accept(); нет алёрта
    return pages.mainPage;
  }
}
